When the spmd.code
is NULL
: The code should be already
saved in the file named spmd.file
for using.
When the spmd.code
is not NULL
:
The spmd.code
will be dumped to a temp file (spmd.file
) via the
call writeLines(spmd.code, conn)
where
conn <- file(spmd.file, open = "wt")
. The file will be closed after
the dumping.
When spmd.file
is ready (either dumped from spmd.code
or
provided by the user), the steps below will be followed:
If spmd.file = NULL
, then a temporary file will be generated and
used to dump spmd.code
.
For Unix-alike systems, the command
cmd <- paste(mpicmd, "-np", nranks, mpiopt, rscmd, rscmd spmd.file, ">", log.file, " 2>&1 & echo \"PID=$!\" &")
is executed via system(cmd, intern = TRUE, wait = FALSE, ignore.stdout = TRUE, ignore.stderr = TRUE)
. The log.file
is a temporary file to
save the outputs from the spmd.code
. The results saved to the
log.file
will be read back in and cat
and return
to R.
For OPENMPI, the "--oversubscribe " is added before mpiopt
as
mpiopt <- paste("--oversubscribe ", mpiopt, sep = "")
and is passed to cmd
thereon.
For Windows, the cmd
will be
paste(mpicmd, "-np", nranks, mpiopt, rscmd, rsopt spmd.file)
and is executed via
system(cmd, intern = TRUE, wait = FALSE, ignore.stdout = TRUE, ignore.stderr = TRUE)
.